package com.d3works.apps.account.service.analytic;

import com.d3works.apps.account.db.AnalyticAccount;
import com.d3works.apps.account.db.AnalyticDistributionLine;
import com.d3works.apps.account.db.AnalyticDistributionTemplate;
import com.d3works.apps.account.db.AnalyticMoveLine;
import com.d3works.apps.account.db.Invoice;
import com.d3works.apps.account.db.InvoiceLine;
import com.d3works.apps.account.db.MoveLine;
import com.d3works.apps.account.db.repo.AnalyticMoveLineRepository;
import com.d3works.apps.base.db.Company;
import com.d3works.apps.base.db.Partner;
import com.d3works.apps.base.db.Product;
import com.d3works.exception.D3worksException;
import com.d3works.meta.CallMethod;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;

public interface AnalyticMoveLineService {

  public AnalyticMoveLineRepository getAnalyticMoveLineRepository();

  public BigDecimal computeAmount(AnalyticMoveLine analyticMoveLine);

  public List<AnalyticMoveLine> generateLines(
      AnalyticDistributionTemplate analyticDistributionTemplate,
      BigDecimal total,
      int typeSelect,
      LocalDate date);

  public AnalyticDistributionTemplate getAnalyticDistributionTemplate(
      Partner partner, Product product, Company company, boolean isPurchase)
      throws D3worksException;

  public void updateAnalyticMoveLine(
      AnalyticMoveLine analyticMoveLine, BigDecimal total, LocalDate date);

  public boolean validateLines(List<AnalyticDistributionLine> analyticDistributionLineList);

  @CallMethod
  boolean validateAnalyticMoveLines(List<AnalyticMoveLine> analyticDistributionLineList);

  AnalyticMoveLine computeAnalyticMoveLine(
      MoveLine moveLine, Company company, AnalyticAccount analyticAccount) throws D3worksException;

  AnalyticMoveLine computeAnalyticMoveLine(
      InvoiceLine invoiceLine, Invoice invoice, Company company, AnalyticAccount analyticAccount)
      throws D3worksException;

  AnalyticMoveLine reverse(AnalyticMoveLine analyticMoveLine, AnalyticAccount analyticAccount);

  AnalyticMoveLine reverseAndPersist(
      AnalyticMoveLine analyticMoveLine, AnalyticAccount analyticAccount);

  AnalyticMoveLine generateAnalyticMoveLine(
      AnalyticMoveLine analyticMoveLine, AnalyticAccount analyticAccount);
}
